"""
================================================================================
                     ------------utf-8--------------
================================================================================
@Author: rfdsg
@Create Time: 2023/11/3 - 15:03
@Description:
@Attention:
"""
import pickle

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import interpolate
from mpl_toolkits.mplot3d import axes3d
# 读取重力异常基准数据 A
data = pd.read_pickle("基准1.pickle")
# 假设数据列包括经度、纬度和重力异常值
# with open('基准2.pickle', 'wb') as f:
#     pickle.dump(data, f)
# 使用 interpolate 插值函数来生成更细化的基准图
x = data['纬度']
y = data['经度']
z = data['重力异常值']
"""
=====================================================
=====================================================
"""
# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False  # 用于正常显示负号
fig = plt.figure('Surface', facecolor='lightgray')
# # 创建3D子图
z=  z.values
ax3d = fig.add_subplot(111, projection='3d')
ax3d.set_xlabel('纬度', fontsize=10)
ax3d.set_ylabel('经度', fontsize=10)
ax3d.set_zlabel('重力异常值', fontsize=10)
ax3d.plot_trisurf(x, y, z, cmap='viridis')
# , rstride=50,
	# cstride=50, cmap='jet'
# plt.savefig(dpi = 3000, fname='原始图.png')
plt.show()
"""
===========================================================
"""
# 排序选出不重复值
x_unique = np.sort(x.unique())
y_unique = np.sort(y.unique())
# 通过 meshgrid 创建网格
xi, yi = np.meshgrid(x_unique, y_unique)
zi = interpolate.griddata((x, y), z, (xi, yi), method='cubic')
zi_data = zi.flatten()
# 可视化精细化基准图
plt.contourf(xi, yi, zi, levels=50, cmap='viridis')
plt.colorbar()
plt.title('经纬-重力异常值')
plt.xlabel('纬度')
plt.ylabel('经度')
plt.savefig(dpi = 3000, fname='插值图.png')
plt.show()


